package com.umgsai.thread.thread10;

public class Service {
	private String anyString = new String();
	public void methodA() {
		try {
			synchronized (anyString) {
				System.out.println(Thread.currentThread().getName() + "在" + System.currentTimeMillis() + "进入methodA中的同步块");
				Thread.sleep(3000);
				System.out.println(Thread.currentThread().getName() + "在" + System.currentTimeMillis() + "离开methodA中的同步块");
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	synchronized public void methodB() {
		System.out.println(Thread.currentThread().getName() + "在" + System.currentTimeMillis() + "进入methodB同步方法");
		System.out.println(Thread.currentThread().getName() + "在" + System.currentTimeMillis() + "离开methodB同步方法");
	}
}
